/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package chuiniurobot.message;

import chuiniurobot.GameStatusEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.mina.core.session.IoSession;

/**
 *
 * @author zhengji
 */
public class OpenMatchMessage extends BaseMessage{

    public OpenMatchMessage(IoSession ioSession, String requestJSONStr) {
        super(ioSession, requestJSONStr);
    }

    @Override
    public void execute() {
        
        this.setGameStatus(GameStatusEnum.GameStatusNormal);
        JSONObject jsonObj=JSON.parseObject(this.requestJSONStr);
        
        int win=jsonObj.getIntValue("win");
        int vsPlayerId=jsonObj.getIntValue("vsid");
        if(win ==1){
           this.logger.debug(String.format("[playerid:%d] 胜 [vsPlayerId:%d]"
                   ,this.getPlayerId(),vsPlayerId));
        }else{
            this.logger.debug(String.format("[playerid:%d] 负 [vsPlayerId:%d]"
                   ,this.getPlayerId(),vsPlayerId));
        }
     }
    
}
